requirejs(['./config'], () => {
  requirejs(['url','template','header', 'footer'], (url,template) => {
        class Index {
            constructor() {
                this.getData().then(resp => {
                    this.showlist(resp)
                   
                  })
            }
          
            getData () {
                return new Promise(resolve => {
                  $.get(`${url.rapBaseUrl}/list`,  resp => {
                    resolve(resp)
                  })
                })
              }
              showlist (resp) {
                console.log(resp)
                // 渲染模板引擎
                if (resp.code === 200) {
                  
                  // detail详情数据需要存下来为将来加购物车使用
                  let { body } = resp
                  // console.log(detail)
                  // rap2才需要在后面多写一个id，真实接口不需要
                   this.body = body
                  
                  let html = template('showList', {
                    ...this.body
                  })
                  $('#goods-list').html(html)
                }
              }
        }
        new Index()
    })
})
